package reportily

import (
	"zy10/global"
	"zy10/model"
)

func LoginUser(name string) (user model.User, err error) {
	err = global.DB.Where("name = ?", name).Find(&user).Limit(1).Error
	if err != nil {
		return model.User{}, err
	}
	return user, nil
}

func Register(name string, password string) (user model.User, err error) {
	user = model.User{
		Name:     name,
		Password: password,
	}
	err = global.DB.Create(&user).Error
	if err != nil {
		return model.User{}, err
	}
	return user, nil
}

func List() (user []model.User, err error) {
	err = global.DB.Find(&user).Error
	if err != nil {
		return []model.User{}, err
	}
	return user, nil
}
